package fun.xinnix;

import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) throws MqttException {
        System.out.println("Hello World!");
        String broker = "tcp://192.168.174.128:1883";
// TLS/SSL
// String broker = "ssl://broker.emqx.io:8883";
        String username = "admin";
        String password = "xin5528484";
        String clientid = "demo1";
        MqttClient client = new MqttClient(broker, clientid, new MemoryPersistence());
        MqttConnectOptions options = new MqttConnectOptions();
        options.setUserName(username);
        options.setPassword(password.toCharArray());
        client.connect(options);


        client.subscribe("article");
    }
}
